#include "aerial\vulcan.h"
#include "hge\hgecolor.h"

float Vulcan::LastFireList[10] = {0.f};

Vulcan::Vulcan(hgeResourceManager* hgeResMan, float _sx, float _sy, float _vx, float _vy, float cTime, int playerId)
	: Weapon(hgeResMan, 10.f, playerId), sx(_sx), sy(_sy), d(_vx, _vy)
{
	LastFireList[playerId] = cTime;
	t_range = 0.f;

	psInner = new hgeParticleSystem(&hgeResMan->GetParticleSystem("ps.vulcan.inner")->info);
	psInner->info.fSizeStart = 2.0;
	/*psInner->info.colColorStart.r = -1;
	psInner->info.colColorEnd.r = -1;*/
	psInner->info.colColorStart.r = 1.0;
	psInner->info.colColorStart.g = 1.0;
	psInner->info.colColorStart.b = 1.0;
	
	psInner->info.colColorEnd.r = 1.0;
	psInner->info.colColorEnd.g = 1.0;
	psInner->info.colColorEnd.b = 1.0;

	psInner->info.nEmission = 100;
	psInner->info.fParticleLifeMin = 2.3f;

	psOuter = new hgeParticleSystem(&hgeResMan->GetParticleSystem("ps.vulcan.outer")->info);
	/*psOuter->info.colColorStart.r = -1;
	psOuter->info.colColorEnd.r = -1;*/
	psOuter->info.colColorStart.r = 0;
	psOuter->info.colColorStart.g = 0;
	psOuter->info.colColorStart.b = 1.0;
	
	psOuter->info.colColorEnd.r = 0;
	psOuter->info.colColorEnd.g = 0;
	psOuter->info.colColorEnd.b = 1.0;

	psOuter->info.nEmission = 100;
	psOuter->info.fParticleLifeMin = 2.3f;

	psInner->FireAt(sx, sy);
	psOuter->FireAt(sx, sy);
}

void Vulcan::render()
{
	psOuter->Render();
	psInner->Render();
}

bool Vulcan::update(float dt)
{
	t_range += 1000.f * dt;
	if (t_range > 600.f) t_range = 0.f;

	psInner->MoveTo(sx+d.x*t_range, sy+d.y*t_range);
	psOuter->MoveTo(sx+d.x*t_range, sy+d.y*t_range);
	
	psOuter->Update(dt);
	psInner->Update(dt);
	return false;
}

Vulcan::~Vulcan()
{
	delete psInner;
	delete psOuter;
}